﻿using System.ComponentModel.DataAnnotations;
using Abp.Auditing;
using Abp.Authorization.Users;
using Abp.Domain.Entities;

namespace ARchGL.Platform.Authorization.Users.Dto
{
    //Mapped to/from User in CustomDtoMapper
    public class UserEditDto : IPassivable
    {
        /// <summary>
        /// Set null to create a new user. Set user's Id to update a user
        /// </summary>
        public long? Id { get; set; }

        private string name;
        [Required]
        [StringLength(AbpUserBase.MaxNameLength)]
        public string Name
        {
            get => name;
            set => name = value?.Trim();
        }

        private string surname;
        [Required]
        [StringLength(AbpUserBase.MaxSurnameLength)]
        public string Surname
        {
            get => surname;
            set => surname = value?.Trim();
        }

        private string userName;
        [Required]
        [StringLength(AbpUserBase.MaxUserNameLength)]
        public string UserName
        {
            get => userName;
            set => userName = value?.Trim();
        }

        private string emailAddress;
        [Required]
        //[EmailAddress]
        [StringLength(AbpUserBase.MaxEmailAddressLength)]
        public string EmailAddress
        {
            get => emailAddress;
            set => emailAddress = value?.Trim();
        }

        private string phoneNumber;
        [StringLength(UserConsts.MaxPhoneNumberLength)]
        public string PhoneNumber
        {
            get => phoneNumber;
            set => phoneNumber = value?.Trim();
        }

        // Not used "Required" attribute since empty value is used to 'not change password'
        [StringLength(AbpUserBase.MaxPlainPasswordLength)]
        [DisableAuditing]
        public string Password { get; set; }

        public bool IsActive { get; set; }

        public bool ShouldChangePasswordOnNextLogin { get; set; }

        public virtual bool IsTwoFactorEnabled { get; set; }

        public virtual bool IsLockoutEnabled { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public virtual string Avatar { get; set; }
        /// <summary>
        /// 用户类型
        /// </summary>
        public virtual UserType Type { get; set; }
        /// <summary>
        /// 职位信息
        /// </summary>
        public virtual string Position { get; set; }
        /// <summary>
        /// 性别：1男、2女
        /// </summary>
        public virtual int Gender { get; set; }

    }
}